<template>
	<view>
		<view class="u-page">
			<view class="u-demo-block">
				<view class="u-demo-block__content" v-for="(item ,index) in messageList" :key="index">
					<view class="album">
						<view class="album__avatar">
							<image :src="item.avatarUrl" mode=""
								style="width: 36px;height: 36px;border-radius: 5px;">
							</image>
						</view>
						<view class="album__content">
							<u--text :text="item.nickname" size="17" color="#506591"></u--text>
							<u--text margin="0 0 8px 0" :text="item.desc"></u--text>
							<u-album :urls="item.imgs" @albumWidth="getWidth"></u-album>
						</view>
					</view>
					<u-divider></u-divider>
				</view>
			</view>
			<view class="newMessage" @click="addNav()">
				<view class="messageTitle">
					<u-icon name="plus" color="#fff" size="16"></u-icon>
					发布
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	import request from '@/utills/request.js'
	export default {
		data() {
			return {
				messageList: []
			}
		},
		onLoad() {
			this.getMessageList()
		},
		onShow() {
			this.getMessageList()
		},
		methods: {
			getWidth(width) {
				// console.log(width);
			},
			addNav() {
				uni.navigateTo({
					url: './addMessage/addMessage'
				})
			},
			async getMessageList() {
				let res = await request({
					method: 'get',
					url: 'msg/get'
				})
				// console.log(res);
				if(res.data.code == 200) {
					this.messageList = res.data.data
				}
			}
		}
	}
</script>

<style>
	.newMessage {
		display: flex;
		justify-content: center;
		align-items: center;
		position: fixed;
		bottom: 0;
		background-color: #1565C0;
		height: 60px;
		width: 120%;
		left: -10%;
	}

	.messageTitle {
		font-size: 16px;
		color: #fff;
		display: flex;
		justify-content: center;
		align-items: center;
	}
</style>

<style lang="scss">
	.album {
		@include flex;
		align-items: flex-start;

		&__avatar {
			padding: 5px;
			border-radius: 3px;
		}

		&__content {
			margin-left: 10px;
			flex: 1;
		}
	}

	.u-page {
		padding: 15px 20px;
	}
</style>
